"""
-*- coding:utf-8 -*-
最终版web自动化
Author: Free
DataTime: 2020/7/1 17:55

"""

from WebSite.tools.ReadConfig import ReadConfig
from time import sleep
from WebSite.PubilcTask.TaskPublic import TaskPublic


class MyAssets(TaskPublic):
    """
    我的资产
    """
    def my_assets(self):
        """
        进入我的资产
        :return:
        """
        try:
            self.b.find_element_by_css_selector('body > div.appBigBox > div.appbox > div > div.homeBannerAndHeadBox > div.homeHeadBox > div > div > ul > li:nth-child(1) > div').click()
            sleep(2)
            print("点击我的资产")
            self.b.find_element_by_css_selector('body > div.appBigBox > div.appbox > div > div.personalcenterHead > div > div > ul > li:nth-child(1) > div > div > div > div.estimatedBalanceBox').click()
            print("进入我的资产成功")
        except Exception as e:
            print('进入我的资产失败', e)

    def my_assets_history(self):
        """
        我的资产中的历史记录
        :return:
        """
        try:
            self.b.find_element_by_css_selector('body > div.appBigBox > div.appbox > div > div.personalcenterBodyBox > div > div > div.estimatedValueContent > div.estimatedValueHeader > div.estimatedValueHeaderRight').click()
            self.assertEqual(self.b.current_url, ReadConfig.url_history.value, '进入历史记录成功')
        except:
            print("进入历史记录失败")
